<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class user_share extends CI_Controller
{
    private $user_id;
	function __construct()
	{
		parent::__construct();
        $this->load->config('layout', TRUE);
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		$this->load->library('security');
		$this->load->library('tank_auth');
		$this->load->library('backyard_view');
        $this->load->library('houseme_view');
        $this->load->library('facebook');
		$this->lang->load('tank_auth');
		$this->lang->load('backyard');
        $this->load->model('post_model');
        $this->user_id = $this->session->userdata('user_id');
	}

	function index(){}

    function detail(){//show post detail
        $post_id = $this->uri->segment(3);
        $data = array();
        $data = $this->input->get(); // returns all GET items with XSS filter
        $data['post'] = $this->post_model->get_share_by_id($post_id);
        if(isset($data['q'])){
            $data['keyword'] = urldecode($data['q']);
            $data['previous_next_post'] = $this->post_model->get_previous_next_share_by_current_id_and_keyword($post_id,$data['keyword']);
        }
        elseif(isset($data['c'])){
            $data['category_id'] = $data['c'];
            $temp = array();
            $temp['category'] = $this->config->item('category', 'layout');
            $category_string = $temp['category'][$data['category_id']];
            $data['previous_next_post'] = $this->post_model->get_previous_next_share_by_current_id_and_category_string($post_id,$category_string);
        }
        else{
            $data['previous_next_post'] = $this->post_model->get_previous_next_share_by_current_id($post_id);
        }


        // get related post
        // 1) same category
        $data['related_post'] = $this->post_model->get_related_post_by_current_share($data['post']);
        
        $data['category'] = $this->config->item('category', 'layout');
        $data['login_area'] = $this->load->view('houseme/login_area', '', true);
        $this->load->view('houseme/share', $data);
    }

    
}

/* End of file backyard.php */
/* Location: ./application/controllers/backyard.php */